package com.naiterui.ehp.bs.patient.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.naiterui.ehp.bp.domain.PatientRecord;
import com.naiterui.ehp.bs.patient.dao.IPatientRecordDao;
import com.naiterui.ehp.bs.patient.repository.IApPatientRecordRepository;

@Component
public class ApPatientRecordDaoImpl implements IPatientRecordDao {

    @Autowired
    private IApPatientRecordRepository patientRecordRepository;

    @Override
    public void saveOrUpdate(PatientRecord record) {
        patientRecordRepository.save(record);
    }

    @Override
    public List<PatientRecord> getContactRecords(List<Long> contactIds) {
        List<PatientRecord> records = new ArrayList<>();
        if (contactIds == null || contactIds.size() == 0) {
            return records;
        }
        records = patientRecordRepository.findByTypeAndPatientIdIn(PatientRecord.RECORD_TYPE_CONTACTS, contactIds);
        return records;
    }

}
